package com.demo;

/*
线程成员变量测试
 */
class Demo4Thread extends Thread {
    public boolean runing = true;
    private String name;
    Demo4Thread(String name) {
        this.name = name;
    }
    @Override
    public void run() {
        while (this.runing) {
            System.out.println(this.name);
        }
    }
}
public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Demo4Thread t1 = new Demo4Thread("t1");
        Demo4Thread t2 = new Demo4Thread("t2");
        t1.start();
        t2.start();
        Thread.sleep(3000);
        t1.runing = false;
    }
}
